package myBot;

public class distances {
	public static double distanceToWall(double heading,double sizeX, double sizeY, double posX, double posY){
		double distance;
		if(Math.cos(heading)>0){
			distance=((sizeY-posY)/Math.cos(heading));
		}else if(Math.cos(heading)<0){
			distance=(posY/Math.cos(Math.PI-heading));
		}else{
			distance=Double.POSITIVE_INFINITY;
		}
		if(Math.cos(Math.PI/2-heading)>0){
			distance=Math.min(distance, ((sizeX-posX)/Math.cos(Math.PI/2-heading)));
		}else if(Math.cos(Math.PI/2-heading)<0){
			distance=Math.min(distance, ((posX)/Math.cos(Math.PI*3/2-heading)));
		}
		return distance;
	}
	
	public static double intervall(double valX, double maxX){
		return 1/(Math.pow(2, ((valX*5)/maxX)));
	}
	
}
